<?php

namespace app\index\model;

use think\Model;
use think\Db;

class Article extends Model
{

    //文章详情
    public function art_detail($id){
        $data =  Article::where('id', $id)->find();
        return $data;
    }

    //最新文章推荐
    public function getarticle_tui($typez){
        $data = db('article')->alias('a')->where(['a.rec' => 1, 'a.typez' => $typez])->field('a.*,b.catename')->join('lan_cate b','a.cateid=b.id')->select();
        // $data = Article::all(['rec' => 1]);
        if($data!=''){
            return $data;
        }
        return false;
    }

     //其他文章推荐
     public function getarticle_qi($typez){
        $data = Article::all(['rec' => 0, 'typez' => $typez]);
        if($data!=''){
            return $data;
        }
        return false;
    }

    public function get_cate_art($cid){
        $data = db('article')->where(['cateid' => $cid , 'rec' => 1])->field('a.*,b.catename')->alias('a')->join('lan_cate b','a.cateid=b.id')->select();
        // $cateart = Article::where('cateid' , $cid)->select();
        return $data;
    }

    public function get_cate_art_qi($cid){
        $data = db('article')->where(['cateid' => $cid , 'rec' => 0])->select();
        // $cateart = Article::where('cateid' , $cid)->select();
        return $data;
    }

}
